<template>
  <basic-container :btnFlag = true>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <div class="card-body">
        <avue-crud :data="subjectListData"
                   :option="tableoption"
                   :page="page"
                   :table-loading="tableLoading"
                   @size-change="sizeChange"
                   @current-change="currentChange"
                   @refresh-change="refreshChange"
                   @search-change="searchChange"
                   @search-reset="refreshChange"
                   class="menu-min-height">
          <template slot-scope="scope" slot="menu">
            <div class="menu-title" @click.stop="connectionList(scope.row,scope.index)">
              <i class="iconfont iconview icon-primary"></i>
              <p class="menu-title-text">规划衔接</p>
            </div>
          </template>
        </avue-crud>
      </div>
    </div>
  </basic-container>
</template>
<script>
  import {getSubjectList} from "@/api/subject";
  import {Subject_DIC,PROJECT_DIC} from '@/const/dict';
  import { resultList ,resultPageDept} from "@/api/planning/result";
  export default {
    name: "planningConnection",
    created(){
      this.getResultList(this.page)
    },
    data(){
      return{
        headerData:{
          title:'规划衔接'
        },
        subjectListData:[],
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        tableoption: {
          page: true,
          menuWidth:120,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn:false,
          keyId: "id",
          column: [
            {
              label: "规划名称",
              prop: "title",
              cell: true,
//              search:true,
            },
            {
              label: "规划名称",
              prop: "titleLike",
              cell: true,
              search:true,
              hide:true,
            },
            {
              label: "规划类型",
              width: 100,
              prop: "category",
              type: "select",
              dicData: PROJECT_DIC.CATEGORY,
              cell: true
            },
            {
              label: "申报单位",
              width: 140,
              prop: "orgName",
              cell: true
            },
            {
              label: "年份",
              width: 100,
              prop: "year",
              cell: true
            },
          ]
        },
        tableLoading:false,
        xieorgCodeVisiblesubmit:false,
        titleLikes: '',
//        categorys:''
      }
    },
    methods:{
      // 课题征集意见跳转
      connectionList(row){
        let src = `/connectionList/detail/${row.achievementId}`;
        this.$router.push({
          path: src,
          query:{
            title:row.title,
            orgName:row.orgName,
          }
        })
      },
      searchChange(params) {
        this.page.currentPage = 1
        this.getResultList(this.page, this.dealSearchParam(params))
      },
      // 处理搜索过滤
      dealSearchParam (params) {
        if (params.titleLike) {
          params.titleLike = params.titleLike;
//          params.title = ''
        }else{
          params.titleLike =""
        }
//        if (params.category) {
//          params.categorys = params.category
//        }
        this.titleLikes=  params.titleLike;
//        this.categorys= params.categorys

        return params;
      },
      refreshChange(){
        this.getResultList(this.page);
      },
      currentChange(currentPage) {
        var page = this.page;
        page.currentPage = currentPage;
        var params={titleLike: this.titleLikes};
        this.getResultList(page, params);
      },
      sizeChange(pageSize) {
        var page = this.page;
        page.pageSize = pageSize;
        var params={titleLike: this.titleLikes};
        this.getResultList(page, params);
      },
      getResultList(page,params){
        this.tableLoading = true;
        resultPageDept(Object.assign({
          current: page.currentPage,
          size: page.pageSize,
          states:'2',
        }, params)).then(response => {
          this.subjectListData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false
        })
      },
    }
  }
</script>

<style lang="scss" scoped>

</style>
